<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>绩效考核-下级对上级测评</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="static/css/font.css">
<link rel="stylesheet" href="static/css/xadmin.css">
<script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="static/lib/layui/layui.js"></script>
<script type="text/javascript" src="static/js/xadmin.js"></script>
</head>

<body class="layui-anim layui-anim-up">

	<div class="x-nav">
		<span class="layui-breadcrumb"> <a>首页</a> <a>民主测评</a> <a> <cite>下级对上级测评</cite></a>
		</span> <a class="layui-btn layui-btn-small"
			style="line-height: 1.6em; margin-top: 3px; float: right"
			href="javascript:location.replace(location.href);" title="刷新"> <i
			class="layui-icon" style="line-height: 30px">ဂ</i></a>
	</div>
	<div class="x-body" id="container">
		<div class="demoTable">
			员工号：
			<div class="layui-inline">
				<input type="number" id="e_id" name="e_id" required
					lay-verify="number" autocomplete="off" class="layui-input" value="" />
			</div>
			<button class="layui-btn" data-type="reload">查&nbsp;&nbsp;询</button>
		</div>
		<div style="text-align: center">
        <div span class="x-red demoTable" id='demo1'>为保证数据不丢失,请随时点击提交</div>
        <table id="demo1" class="layui-table" lay-filter="demo1"></table>
        </div>
		<div style="text-align: center">
			<div class="demoTable">（*请填入1-4的数字，1：好、2：较好、3：一般、4：较差*）</div>
			<table id="demo" class="layui-table" lay-filter="demo"></table>
		</div>
		<div class="layui-inline">
			<a class="layui-btn layui-btn-danger batchUnlock" id="sbmt" >
			<i class="layui-icon layui-icon-key"></i>提交</a>
		</div>
	</div>
</body>
<script>
    layui.use(['laydate','table','util'], function(){
            var laydate = layui.laydate
            ,table = layui.table;

          //第一个实例
         table.render({
             elem: '#demo'
            ,height: 'full'
            ,url: 'employeeSevaluation.do'
            ,page: false
            ,initSort: {field: 'eAccount', type: 'desc'}
            ,id:'demo'
            ,cols: [[ //表头
               {field:'eAccount', rowspan:2, title: '工号', width:120, align: 'center',fixed: 'left'}
              ,{field: 'eName', rowspan:2, title: '姓名', width:80, align: 'center',fixed: 'left'}
              ,{field: 'aFinish', rowspan: 2, title: '完成状态', width: 100, align: 'center', templet: '#sexTpl',fixed: 'left'}
              ,{minWidth:100, title:'德', align:'center',colspan:4}
              ,{minWidth:100, title:'能', align:'center',colspan:6}
              ,{minWidth:100, title:'勤', align:'center',colspan:2}
              ,{minWidth:100, title:'绩', align:'center',colspan:5}
              ,{minWidth:100, title:'廉', align:'center',colspan:2}
             ],
                [
                	 {field:'sTargetscore1', title:'政治品质' ,minWidth:100, align: 'center',edit:'number'}
                	,{field:'sTargetscore2', title:'职业道德' ,minWidth:100, align: 'center',edit:'number'}
                    ,{field:'sTargetscore3', title:'社会公德' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore4', title:'家庭美德' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore5', title:'政治鉴别能力' , minWidth:120,align: 'center',edit:'number'}
                    ,{field:'sTargetscore6', title:'沟通协调能力' , minWidth:120,align: 'center',edit:'number'}
                    ,{field:'sTargetscore7', title:'执行能力' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore8', title:'依法行政能力' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore9', title:'应急处突能力' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore10', title:'群众工作能力' , minWidth:100,align: 'center',edit:'number'}
                    // ,{field:'sTargetscore11', title:'日常出勤' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore12', title:'责任心' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore13', title:'工作积极性' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore14', title:'工作负荷' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore15', title:'工作质量' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore16', title:'工作时效' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore17', title:'综合效益' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore18', title:'工作过程' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore19', title:'廉洁自律' , minWidth:100,align: 'center',edit:'number'}
                    ,{field:'sTargetscore20', title:'勤俭节约' , minWidth:100,align: 'center',edit:'number'}

                ]
            ]
         });

	var $ = layui.$, active = {
			reload : function() {
				var demoReload = $('#demoReload');
				//执行重载
				table.reload('demo', {
					where : {
						e_id : $("#e_id").val()
					}
				});
			}
		};
		$('.demoTable .layui-btn').on('click', function() {
			var type = $(this).data('type');
			console.log(type);
			active[type] ? active[type].call(this) : '';
		});

		//批量提交  使用封装后的ajax
		$("#sbmt").click(function() {
			const list = table.cache['demo'];
			var len = list.length;
			var flg = "0";
			for (var i = 0; i < len; i++) {
				delete list[i].LAY_TABLE_INDEX;
                list[i].sTargetscore1 = list[i].sTargetscore1.toString().replace(/\s+/g, '');
                list[i].sTargetscore2 = list[i].sTargetscore2.toString().replace(/\s+/g, '');
                list[i].sTargetscore3 = list[i].sTargetscore3.toString().replace(/\s+/g, '');
                list[i].sTargetscore4 = list[i].sTargetscore4.toString().replace(/\s+/g, '');
                list[i].sTargetscore5 = list[i].sTargetscore5.toString().replace(/\s+/g, '');
                list[i].sTargetscore6 = list[i].sTargetscore6.toString().replace(/\s+/g, '');
                list[i].sTargetscore7 = list[i].sTargetscore7.toString().replace(/\s+/g, '');
                list[i].sTargetscore8 = list[i].sTargetscore8.toString().replace(/\s+/g, '');
                list[i].sTargetscore9 = list[i].sTargetscore9.toString().replace(/\s+/g, '');
                list[i].sTargetscore10 = list[i].sTargetscore10.toString().replace(/\s+/g, '');
                list[i].sTargetscore12 = list[i].sTargetscore12.toString().replace(/\s+/g, '');
                list[i].sTargetscore13 = list[i].sTargetscore13.toString().replace(/\s+/g, '');
                list[i].sTargetscore14 = list[i].sTargetscore14.toString().replace(/\s+/g, '');
                list[i].sTargetscore15 = list[i].sTargetscore15.toString().replace(/\s+/g, '');
                list[i].sTargetscore16 = list[i].sTargetscore16.toString().replace(/\s+/g, '');
                list[i].sTargetscore17 = list[i].sTargetscore17.toString().replace(/\s+/g, '');
                list[i].sTargetscore18 = list[i].sTargetscore18.toString().replace(/\s+/g, '');
                list[i].sTargetscore19 = list[i].sTargetscore19.toString().replace(/\s+/g, '');
                list[i].sTargetscore20 = list[i].sTargetscore20.toString().replace(/\s+/g, '');

				var ttv = list[i].sTargetscore1
				if (ttv != '0' && ttv != '1' && ttv != '2' && ttv != '3' && ttv != '4') {
					var flg = "1";
					layer.msg('请输入正确分数,1-4的数字', {
				        time: 20000, //20s后自动关闭
				        btn: '明白了'
                        , btnAlign: 'c' //按钮居中
				    });
					break;
				}
				if (list[i].sTargetscore2 != '0' && list[i].sTargetscore2 != '1' && list[i].sTargetscore2 != '2'
						&& list[i].sTargetscore2 != '3' && list[i].sTargetscore2 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore3 != '0' && list[i].sTargetscore3 != '1' && list[i].sTargetscore3 != '2'
						&& list[i].sTargetscore3 != '3' && list[i].sTargetscore3 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore4 != '0' && list[i].sTargetscore4 != '1' && list[i].sTargetscore4 != '2'
						&& list[i].sTargetscore4 != '3' && list[i].sTargetscore4 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore5 != '0' && list[i].sTargetscore5 != '1' && list[i].sTargetscore5 != '2'
						&& list[i].sTargetscore5 != '3' && list[i].sTargetscore5 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore6 != '0' && list[i].sTargetscore6 != '1' && list[i].sTargetscore6 != '2'
						&& list[i].sTargetscore6 != '3' && list[i].sTargetscore6 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore7 != '0' && list[i].sTargetscore7 != '1' && list[i].sTargetscore7 != '2'
						&& list[i].sTargetscore7 != '3' && list[i].sTargetscore7 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore8 != '0' && list[i].sTargetscore8 != '1' && list[i].sTargetscore8 != '2'
						&& list[i].sTargetscore8 != '3' && list[i].sTargetscore8 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore9 != '0' && list[i].sTargetscore9 != '1' && list[i].sTargetscore9 != '2'
						&& list[i].sTargetscore9 != '3' && list[i].sTargetscore9 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore10 != '0' && list[i].sTargetscore10 != '1' && list[i].sTargetscore10 != '2'
						&& list[i].sTargetscore10 != '3' && list[i].sTargetscore10 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore11 != '0' && list[i].sTargetscore11 != '1' && list[i].sTargetscore11 != '2'
						&& list[i].sTargetscore11 != '3' && list[i].sTargetscore11 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore12 != '0' && list[i].sTargetscore12 != '1' && list[i].sTargetscore12 != '2'
						&& list[i].sTargetscore12 != '3' && list[i].sTargetscore12 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore13 != '0' && list[i].sTargetscore13 != '1' && list[i].sTargetscore13 != '2'
						&& list[i].sTargetscore13 != '3' && list[i].sTargetscore13 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore14 != '0' && list[i].sTargetscore14 != '1' && list[i].sTargetscore14 != '2'
						&& list[i].sTargetscore14 != '3' && list[i].sTargetscore14 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore15 != '0' && list[i].sTargetscore15 != '1' && list[i].sTargetscore15 != '2'
						&& list[i].sTargetscore15 != '3' && list[i].sTargetscore15 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore16 != '0' && list[i].sTargetscore16 != '1' && list[i].sTargetscore16 != '2'
						&& list[i].sTargetscore16 != '3' && list[i].sTargetscore16 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore17 != '0' && list[i].sTargetscore17 != '1' && list[i].sTargetscore17 != '2'
						&& list[i].sTargetscore17 != '3' && list[i].sTargetscore17 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore18 != '0' && list[i].sTargetscore18 != '1' && list[i].sTargetscore18 != '2'
						&& list[i].sTargetscore18 != '3' && list[i].sTargetscore18 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore19 != '0' && list[i].sTargetscore19 != '1' && list[i].sTargetscore19 != '2'
						&& list[i].sTargetscore19 != '3' && list[i].sTargetscore19 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
				if (list[i].sTargetscore20 != '0' && list[i].sTargetscore20 != '1' && list[i].sTargetscore20 != '2'
						&& list[i].sTargetscore20 != '3' && list[i].sTargetscore20 != '4') {
					var flg = "1";
					layer.msg('表中存在非法数据,请输入正确分数,1-4的数字', {
						time: 20000, //20s后自动关闭
						btn: '明白了'
						, btnAlign: 'c' //按钮居中
					});
					break;
				}
			}
			if (flg == '0') {
				console.log(list);
				console.log("list=" + JSON.stringify(list));
				$.ajax({
					type : 'post',
					url : 'updateSevaluation.do',
					data : "list=" + JSON.stringify(list),
					dataType : 'json',
					success : function(result) {
						if (result.code == 0) {
							layer.msg(result.msg);
							table.reload('demo', {
								where : {
									e_id : $("#e_id").val()
								}
							});
						} else {
							layer.msg(result.msg);
						}
					}
				});
			}
		});

		//监听单元格编辑
		table.on('edit(demo)', function(obj) {
			var ttv = obj.value //得到修改后的值
			, data = obj.data //得到所在行所有键值
			console.log(obj.data);
			if (ttv != '1' && ttv != '2' && ttv != '3' && ttv != '4') {
				layer.msg('请输入正确分数,1-4的数字', {
			        time: 20000 //20s后自动关闭
			        ,btn: '明白了'
			        ,btnAlign: 'c' //按钮居中
			    });
				/**添加禁用按钮样式
				$("#sbmt").addClass("layui-btn-disabled");
				//真正禁用按钮的语句
				$("#sbmt").attr("disabled", true);
				**/
			}
			/**
			else {
				//去除禁用样式
				$("#sbmt").removeClass("layui-btn-disabled");
				//解除禁用的语句
				$("#sbmt").attr("disabled", false);
			}
			**/
		});

	});
</script>
<script type="text/html" id="sexTpl">
    {{#  if(d.aFinish === "未完成"){ }}
    <span class="layui-badge layui-bg-red">未完成</span>
    {{#  } else { }}
    <span class="layui-badge layui-bg-green">已完成</span>
    {{#  } }}
</script>
</html>
